home *** CD-ROM | disk | FTP | other *** search
- ; Uses the Zortech assembler macros; written for small model. If you
- ; need to assemble without the macros, the beg/end data/code should be
- ; obvious, and I think you can ignore the ES stuff. I don't remember
- ; exactly what that's for now... Oh, an P is the offset (with a normal
- ; stack frame) of the first argument, of course.
-
- include macros.asm
-
- begdata
- public fossilMaxFunc, fossilRevision
- fossilMaxFunc dw 0
- fossilRevision dw 0
- enddata
-
- begcode
-
- ; int pascal port_open(int port)
- ;
- public PORT_OPEN
- PORT_OPEN proc
- push bp
- mov bp, sp
- mov ah, 4 ;fossil function 4
- mov dx, P[bp] ;port argument
- xor bx, bx ;bx MUST NOT be 0x4f50!
- int 014h ;call the fossil
- cmp ax, 01954h ;if call succeeded
- jne open_5
- xor ah, ah
- mov al, bl
- mov fossilMaxFunc, ax ; store fossil info in globals
- mov al, bh
- mov fossilRevision, ax
- xor al, al ; return 0
- jmp short open_9
- open_5: ;else
- mov ax, -1 ; return -1
- open_9:
- pop bp
- ret 2
- PORT_OPEN endp
-
-
- ; int pascal port_close(int port)
- ;
- public PORT_CLOSE
- PORT_CLOSE proc
- push bp
- mov bp, sp
- mov ah, 5 ;fossil function 5
- mov dx, P[bp] ;load port argument
- int 014h ;call fossil
- xor ax, ax ;always returns 0
- pop bp
- ret 2
- PORT_CLOSE endp
-
-
- ; int port_status(int port)
- ;
- public PORT_STATUS
- PORT_STATUS proc
- push bp
- mov bp, sp
- mov ah, 3 ;fossil function 3
- mov dx, P[bp] ;port argument
- int 014h ;call the fossil
- ;return value is in ax
- pop bp
- ret 2
- PORT_STATUS endp
-
-
- ; void pascal port_setBaud(int port, int baudCode)
- ;
- public PORT_SETBAUD
- PORT_SETBAUD proc
- xor ah, ah ;fossil function 0
- two_args:
- push bp
- mov bp, sp
- mov dx, P+2[bp] ;load port argument
- mov al, P[bp] ;load LSByte of second argument
- int 014h ;call fossil
- ;return value in ax or none
- pop bp
- ret 4
- PORT_SETBAUD endp
-
-
- ; void pascal port_flow(int port, int mode)
- ;
- public PORT_FLOW
- PORT_FLOW proc
- mov ah, 15 ;fossil function 15
- jmp short two_args
- PORT_FLOW endp
-
-
- ; void port_dtr(int port, int enable)
- ;
- public PORT_DTR
- PORT_DTR proc
- push bp
- mov bp, sp
- mov ah, 6 ;fossil function 6
- mov dx, P+2[bp] ;load port argument
- mov cx, P[bp]
- or cx, cx
- jne dtr_5 ;pass enable ? 1 : 0 to fossil
- xor al, al
- jmp short dtr_9
- dtr_5:
- mov al, 1
- dtr_9:
- int 014h ;call the fossil
- pop bp
- ret 4
- PORT_DTR endp
-
-
- ; int pascal port_read(int port, char *buf, int n)
- ;
- public PORT_READ
- PORT_READ proc
- mov ah, 24 ;fossil function 24
- read_write:
- push bp
- mov bp, sp
- push di
- pushES
- mov dx, P+2+SIZEPTR[bp] ;load port argument
- if SPTR
- setESeqDS
- mov di, P+2[bp]
- else
- les di, P+2[bp]
- endif ;load buffer address
- mov cx, P[bp] ;load buffer size
- int 014h ;call fossil
- ;return is already in ax
- ; restore regs?
- popES
- pop di
- pop bp
- ret 4 + SIZEPTR
- PORT_READ endp
-
-
- ; int pascal port_write(int port, char *buf, int n)
- ;
- public PORT_WRITE
- PORT_WRITE proc
- mov ah, 25 ;fossil function 25
- jmp short read_write ;rest of code is shared w/read
- PORT_WRITE endp
-
- endcode
-
-
- end
-